<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>

    <script>
    </script>
    <script>
        conutDown();

        function conutDown(time) {
            var num = +new Date(); //当前时间
            var nums = +new Date(time); //用户输入时间

            var times = (nums - num) / 1000; //获取总秒 /60/60/24/60/60/24
            var day = (parseInt(times / 60 / 60 / 24)).toString().padStart('2',0); //天 /60/60/24/60/
            var h = (parseInt(times / 60 / 60 % 24)).toString().padStart('2',0); //小时 
            var min = (parseInt(times / 60 % 60)).toString().padStart('2',0); //分钟 /60%60
            var s = (parseInt(times % 60)).toString().padStart('2',0); //秒  %60
            return day + "天" + h + '时' + min + ":" + s;
        }

        // function isZero(num) {
        //     return num = parseInt(num) >= 10 ? num : '0' + num;
        // }
        setInterval(function() {
            console.log(conutDown('2023-9-8 12:00'));
        }, 1000);
        // console.log(new Date().valueOf() / 1000);
    </script>
</body>

</html>